﻿<UserControl x:Class="Profit.Controls.AgentControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Resources="clr-namespace:Profit.Resources"
             mc:Ignorable="d" 
             d:DesignHeight="426"
             d:DesignWidth="463" >

    <UserControl.Resources>
        <Style x:Key="AgentPortraitImageStyle" TargetType="{x:Type Image}">
            <Setter Property="MinWidth" Value="32"/>
            <Setter Property="MinHeight" Value="32"/>
            <Setter Property="MaxWidth" Value="64" />
            <Setter Property="MaxHeight" Value="64"/>
            <Setter Property="Source" Value="/Profit;component/Resources/Icons/agent_default_64.png"/>
            <Setter Property="Opacity" Value="0.8" />
            <Setter Property="ToolTip" Value="Right click to select a picture"/>
            <Setter Property="UseLayoutRounding" Value="False" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Agent.HasImageSource, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
                    <Setter Property="Source" Value="{Binding Path=Agent.ImageSource, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
                    <Setter Property="Opacity" Value="1" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <!--<ColumnDefinition />-->
        </Grid.ColumnDefinitions>

        <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" Margin="5,2" VerticalAlignment="Top">
            <Image Margin="2" Style="{StaticResource AgentPortraitImageStyle}">
                <Image.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Select a portrait" Command="{Binding SelectPortraitCommand}" />
                    </ContextMenu>
                </Image.ContextMenu>
                <!--<Image.CacheMode>
                    <BitmapCache RenderAtScale="1" EnableClearType="False" SnapsToDevicePixels="True" />
                </Image.CacheMode>-->
            </Image>
            <TextBlock Text="{x:Static Resources:Messages.label_name}" VerticalAlignment="Top" Margin="5,5,5,0"/>
            <TextBox Text="{Binding Agent.Name, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=UserControl}}" Margin="0,2,0,0" VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
        </StackPanel>

        <!--<Border Grid.Row="0" Grid.Column="1">
            <local:AgentAttributesControl 
                x:Name="agentAttributes" 
                VerticalAlignment="Top"
                HorizontalAlignment="Right"
                Width="200" Height="100"
                Agent="{Binding Agent, RelativeSource={RelativeSource AncestorType=UserControl}}" />
        </Border>-->

        <Border Grid.Row="1" Grid.ColumnSpan="2">
            <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                <StackPanel Orientation="Vertical">

                    <HeaderedItemsControl
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_corporation}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.CorporationExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"    
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_electronics}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.ElectronicsExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_engineering}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.EngineeringExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />


                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_weapon_usage}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.WeaponUsageExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_industry}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.IndustryExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_nexus_management}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.NexusManagementExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_relations}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.RelationsExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_robot_control}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.RobotControlExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_finances}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.FinancesExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                    <HeaderedItemsControl 
                    Background="{StaticResource WindowBackgroundBrush}"
                    Margin="2"
                    VerticalAlignment="Stretch" 
                    Header="{x:Static Resources:Messages.label_extension_group_mineral_extraction}" 
                    Style="{StaticResource ExtensionItemsControlStyle}"
                    ItemsSource="{Binding IsAsync=True, Path=Agent.MineralExtractionExtensions, RelativeSource={RelativeSource AncestorType=UserControl}}" />

                </StackPanel>
            </ScrollViewer>
        </Border>
    </Grid>
</UserControl>
